<template>
  <div class="devicestate-container">
    <div class="page-title">
      <svg class="icon icon-zhibanguanli" aria-hidden="true">
        <use xlink:href="#icon-zhibanguanli"/>
      </svg>
      <span>设备状态查询</span>
      <pagego :path="devicestatePath"/>
    </div>
    <div class="main-content">
      <div class="tool-bar">
        <!-- <el-pagination
          :current-page="currentPage4"
          :page-sizes="[100, 200, 300, 400]"
          :page-size="100"
          :total="400"
          layout=" prev, pager, next, sizes, total "
          @size-change="handleSizeChange"
          @current-change="handleCurrentChange"/> -->
        <span style="font-size: 14px;">停车场</span>
        <el-select v-model="parkingvalue" placeholder="请选择" size="small">
          <el-option
            v-for="item in parkingoptions"
            :key="item.parkingvalue"
            :label="item.parkinglabel"
            :value="item.parkingvalue"/>
        </el-select>
        <span style="font-size: 14px;">设备状态</span>
        <el-select v-model="statevalue" placeholder="请选择" size="small">
          <el-option
            v-for="item in stateoptions"
            :key="item.statevalue"
            :label="item.statelabel"
            :value="item.statevalue"/>
        </el-select>
        <div class="search-box">
          <span style="font-size: 14px;margin-right: 10px;">设备查询</span>
          <el-input
            v-model="searchText"
            size="small"
            clearable/>
          <el-button size="small" type="primary" icon="el-icon-search">查询</el-button>
        </div>
      </div>
      <el-table
        :data="tableData"
        border
        stripe
        style="width: 100%">
        <el-table-column
          type="selection"
          align="center"
          width="55"/>
        <el-table-column
          prop="id"
          label="序号"
          align="center"
          width="50"/>
        <el-table-column
          prop="parking_name"
          label="所属停车场"/>
        <el-table-column
          prop="ename"
          label="设备名称"/>

        <el-table-column
          prop="devicetype"
          width="120"
          label="设备类型"/>

        <el-table-column
          prop="manufacturer"
          label="厂商"/>

        <el-table-column
          prop="mngperson"
          width="120"
          label="设备管理负责人"/>

        <el-table-column
          prop="status"
          width="80"
          label="状态">
          <template slot-scope="scope">
            <span :class="'color-span-' + scope.row.status" class="status-span">{{ scope.row.status | statusFilter }}</span>
          </template>
        </el-table-column>

      </el-table>
      <div class="tool-bar">
        <el-pagination
          :current-page="currentPage4"
          :page-sizes="[100, 200, 300, 400]"
          :page-size="100"
          :total="400"
          layout=" prev, pager, next, sizes, total "
          @size-change="handleSizeChange"
          @current-change="handleCurrentChange"/>
      </div>
    </div>
  </div>
</template>

<script>
import { Message } from 'element-ui'
import Pagego from '@/components/pageGoBtn/index'

export default {
  name: 'DeviceState',
  components: {
    Pagego
  },
  filters: {
    statusFilter: function (status) {
      switch (status) {
        case 1:
          return '正常'
        case 2:
          return '临近期'
        case 3:
          return '已过期'
        case 4:
          return '损坏'
      }
    }
  },
  data () {
    return {
      radio: '1',
      value1: '',
      parkingvalue: 'all',
      parkingoptions: [{
        parkingvalue: 'all',
        parkinglabel: '全部'
      }, {
        parkingvalue: '2',
        parkinglabel: '停车场1'
      }, {
        parkingvalue: '3',
        parkinglabel: '停车场2'
      }, {
        parkingvalue: '4',
        parkinglabel: '停车场4'
      }, {
        parkingvalue: '5',
        parkinglabel: '停车场5'
      }],
      statevalue: 'all',
      stateoptions: [{
        statevalue: 'all',
        statelabel: '全部'
      }, {
        statevalue: '2',
        statelabel: '正常'
      }, {
        statevalue: '3',
        statelabel: '临近期'
      }, {
        statevalue: '4',
        statelabel: '已过期'
      }, {
        statevalue: '5',
        statelabel: '损坏'
      }],
      devicestatePath: '/example/devicestate',
      dialogFormVisible: false,
      form: {
        parking_name: '',
        ename: '',
        devicetype: '',
        buy_date: '',
        mngperson: '',
        manufacturer: '',
        status: 1
      },
      formLabelWidth: '120px',
      currentPage4: 4,
      searchText: '',
      tableData: [{
        id: '1',
        parking_name: '东方雅园东区停车场',
        ename: '中控指纹门禁',
        devicetype: '门禁',
        buy_date: '2016-05-14',
        mngperson: '王志鹏',
        manufacturer: '众科伟业科技有限公司',
        status: 1
      },
      {
        id: '2',
        parking_name: '东方雅园东区停车场',
        ename: '中控指纹门禁',
        devicetype: '门禁',
        buy_date: '2016-05-14',
        mngperson: '王志鹏',
        manufacturer: '众科伟业科技有限公司',
        status: 2
      },
      {
        id: '3',
        parking_name: '东方雅园东区停车场',
        ename: '中控指纹门禁',
        devicetype: '门禁',
        buy_date: '2016-05-14',
        mngperson: '王志鹏',
        manufacturer: '众科伟业科技有限公司',
        status: 3
      },
      {
        id: '4',
        parking_name: '东方雅园东区停车场',
        ename: '中控指纹门禁',
        devicetype: '门禁',
        buy_date: '2016-05-14',
        mngperson: '王志鹏',
        manufacturer: '众科伟业科技有限公司',
        status: 4
      },
      {
        id: '5',
        parking_name: '东方雅园东区停车场',
        ename: '中控指纹门禁',
        devicetype: '门禁',
        buy_date: '2016-05-14',
        mngperson: '王志鹏',
        manufacturer: '众科伟业科技有限公司',
        status: 1
      },
      {
        id: '6',
        parking_name: '东方雅园东区停车场',
        ename: '中控指纹门禁',
        devicetype: '门禁',
        buy_date: '2016-05-14',
        mngperson: '王志鹏',
        manufacturer: '众科伟业科技有限公司',
        status: 2
      },
      {
        id: '7',
        parking_name: '东方雅园东区停车场',
        ename: '中控指纹门禁',
        devicetype: '门禁',
        buy_date: '2016-05-14',
        mngperson: '王志鹏',
        manufacturer: '众科伟业科技有限公司',
        status: 3
      },
      {
        id: '8',
        parking_name: '东方雅园东区停车场',
        ename: '中控指纹门禁',
        devicetype: '门禁',
        buy_date: '2016-05-14',
        mngperson: '王志鹏',
        manufacturer: '众科伟业科技有限公司',
        status: 4
      }]
    }
  },
  watch: {},
  methods: {
    handleClick (row) {
      console.log(row)
      this.dialogFormVisible = true
      this.form = row
    },
    handleClickDelete (row) {
      console.log(row.id)
      Message.success('删除成功～')
    },
    submitData () {
      this.dialogFormVisible = false
      Message.success('编辑成功～')
    },
    handleSizeChange (val) {
      console.log(`每页 ${val} 条`)
    },
    handleCurrentChange (val) {
      console.log(`当前页: ${val}`)
    }
  }
}
</script>

<style lang="stylus" scoped>
.devicestate-container{
  margin: 15px;
  color: #828282;
  font-size: 16px;
  background-color: #fff;
  padding-top: 0px;
  .status-span{
    color: #fff;
    display: inline-block;
    padding: 0px 10px;
    font-size: 12px;
  }
  .color-span-1{
    background-color: #5cb85c;
  }
  .color-span-2{
    background-color: #5bc0de;
  }
  .color-span-3{
    background-color: #f0ad4e;
  }
  .color-span-4{
    background-color: #d9534f;
  }
  .el-input{
    display: inline-block;
  }
  .page-title{
    width:100%;
    height: 44px;
    line-height: 44px;
    border-bottom: 1px solid #e5e5e5;
    margin-bottom: 5px;
    padding: 0 15px;
    .icon{
      width: 22px;
      height: 22px;
      position: relative;
      top: 3px;
    }
  }
  .main-content{
    padding: 15px;
    padding-top: 0px;
    .tool-bar {
      padding: 10px 0px;
      position: relative;
      .search-box{
        position: absolute;
        right: 10px;
        top: 10px;
        .el-input{
          width: 120px;
        }
      }
    }
  }
}
</style>
